<?php

require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;

$mq = require_once("customize.php");
$connection = new AMQPStreamConnection($mq['host'], $mq['port'], $mq['user'], $mq['pass']);
$channel = $connection->channel();

$channel->queue_declare('hello', false, false, false, false);

echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";

$callback = function($msg) {
    echo iconv("UTF-8", "GBK", " [get] 接受 ". $msg->body. "\n");
};

$channel->basic_consume('hello', '', false, true, false, false, $callback);

while(count($channel->callbacks)) {
    $channel->wait();
}

